package com.ruozedata.bigdata.lesson03

/**
 * Scala类中的抽象类 需要abstract修饰
 * 类中只有方法和属性 没有实现 ；不能直接实例化
 * 需要被继承
 */
object AbstractApp {
    def main(args: Array[String]): Unit = {

        val student = new Student2()
        println(s"name is: ${student.name}")

        // 匿名子类
        val person: Person2 = new Person2 {
            override val name: String = "pk3"
            override val age: Int = 32

            override def speak(): Unit = println("speak")
        }
    }
}

abstract class Person2 {
    val name:String
    val age:Int

    def speak()
}

class Student2 extends Person2 {
    override val name: String = "PK"
    override val age: Int = 30

    override def speak(): Unit = {
        println("......")
    }
}
